<!-- 
 * @description: 
 * @Author: Islands
 * @Date: 2024-06-23 13:03:31
 * @LastEditTime: 2024-06-24 17:37:38
-->
<!-- <script lang="ts" setup>
import { InwardForm } from '@/components/EpForm';
import { dialogProps, Emits } from '../props';
import { useSwitch } from '@/hooks/index';
import { Plus, Edit, WarningFilled, Close, Upload } from '@element-plus/icons-vue';
import { ref } from 'vue';
const { flag, close, open } = useSwitch();
const emit = defineEmits<Emits>();
const { constants, data, title, width, button } = defineProps(dialogProps);
const formRef = ref<any>();
const handleClose = () => {
    formRef.value.resetForm();
    close();
};
const submitChange = (data: any) => {
    let valid = formRef.value.validateForm();
    if (valid) {
        emit('submitChange', data,function(v:boolean){
            if(v){
                handleClose();
            }
        });
    }
};
</script>
<template>
    <el-button :link="button.link" type="primary" :icon="button.icon" @click.stop.prevent="open">{{ button.title }}</el-button>

    <el-dialog v-model="flag" destroy-on-close draggable :title="title" :width="width" append-to-body :before-close="close" custom-class="adapt-dialog">
        <div class="padding-top-bottom-20 padding-left-right-40">
            <InwardForm ref="formRef" :constants="constants" :data="data" />
            <slog name="form" />
        </div>
        <template #footer>
            <el-button type="info" :icon="Close" auto-insert-space @click="handleClose">{{ $t(`button.cancel`) }}</el-button>
            <el-button type="primary" :icon="Upload" auto-insert-space @click="submitChange(data)">{{ $t(`button.save`) }}</el-button>
        </template>
    </el-dialog>
</template> -->
